//获取品牌总览的数据
import { BrandTableList } from '@/services/BrandTable';
import { useEffect, useState } from 'react';

type BrandTableColumn = {
  title: string;
  dataIndex: string;
};

type BrandTableDataItem = {
  key: string;
  name: string;
  product: string;
};

type BrandTableData = [BrandTableColumn[], BrandTableDataItem[]];

const useBrandTable = (): BrandTableData[] => {
  const [brandTableList, setbrandTableList] = useState<BrandTableData[]>([]);
  useEffect(() => {
    const fetchData = async () => {
      try {
        const res = await BrandTableList();
        if (res.success) {
          console.log('BrandTableList:', res.data.BrandTableData);
          setbrandTableList(res.data.BrandTableData);
        }
      } catch (error) {
        console.error('Error fetching BrandTableList data:', error);
      }
    };

    fetchData();
  }, []);

  return brandTableList;
};

export default useBrandTable;
